<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{$site_opts.site_name}后台管理系统</title>

<script src="../Public/script/app.js" type="text/javascript"></script>
<script type="text/javascript" src="__PUBLIC__/js/jquery.js"></script>
<script language="javascript" type="text/javascript">
function forbid(id){
	var keyValue;
	if (id)
	{
		keyValue = id;
	}else {
		keyValue = getSelectCheckboxValues();
	}
	
	if (!keyValue)
	{
		alert('请选择锁定项！');
		return false;
	}
	
	location.href = "{:U('admin/Cms/forbid','id="+keyValue+"')}";
}

function resume(id){
	var keyValue;
	if(id)
	{
		keyValue = id;
	}else{
		keyValue = getSelectCheckboxValues();
	}
	if (!keyValue)
	{
		alert('请选择解锁项！');
		return false;
	}
	
	location.href = "{:U('admin/Cms/resume','id="+keyValue+"')}";
}

function del(id){
	var keyValue;
	if (id)
	{
		keyValue = id;
	}else {
		keyValue = getSelectCheckboxValues();
	}
	if (!keyValue)
	{
		alert('请选择删除项！');
		return false;
	}

	if (window.confirm('确实要删除选择项吗？'))
	{	
		
		location.href = "{:U('admin/Cms/delete','id="+keyValue+"')}";
	}
}

function add(){
	location.href = "{:U('admin/Cms/addContent')}";
}

function cate(){
	location.href = "{:U('admin/Cms/addCategory')}";
}

function list(){
	location.href = "{:U('admin/Cms/index')}";
}

function getSelectCheckboxValues(){
	var obj = document.getElementsByName('checkList[]');
	var result ='';
	for (var i=0;i<obj.length;i++)
	{
		if (obj[i].checked==true)
				result += obj[i].value+",";

	}
	
	return result.substring(0, result.length-1);
}

 function selectAll(name,selectdName){


    	if($("input[name='"+name+"']").attr('checked')){

    		$("input[name='"+selectdName+"[]']").each(function(){
                $(this).attr('checked',true);
            });

    	}else{
    		$("input[name='"+selectdName+"[]']").each(function(){
                $(this).attr('checked',false);
            });

    	}
    }
</script>

</head>
<body>

<div id="container">

<FORM METHOD=POST ACTION="{:U('admin/Cms/index')}">
 <table width="100%" cellpadding="3" class="form">
 <tr class="top">
      <td class="tit" colspan="6">文章列表 ({$count} 个)</td>
 </tr>
<TR>
	<TD width="50" align="right" class="tRight">标题：</TD>
	<TD width="200"><INPUT TYPE="text" NAME="title" class="medium" value="{$_POST[title]}" ></TD>
	
	<TD width="50" align="right" class="tRight">ID：</TD>
	<TD width="200"><INPUT TYPE="text" NAME="id" class="small" value="{$_POST[id]}" ></TD>
    <TD><input type="submit" value="查 询" class="button hMargin small fLeft " /></TD>
	<TD></TD>
</TR>

</TABLE>
<!-- 高级查询区域 -->
<div  id="searchM" class=" none search cBoth" style="width=80%"></div>

</FORM>
<!-- 功能操作区域结束 -->
<div  style="text-align:left;">
<input type="submit" onclick="del();return false;" value="删除" class="button hMargin small fLeft " />
<input type="submit" onclick="forbid();return false;" value="锁定" class="button hMargin small fLeft " />
<input type="submit" onclick="resume();return false;" value="恢复" class="button hMargin small fLeft " />
</div>
<!-- 列表显示区域  -->
<div class="list" >



<div id="result" class="result none"></div>

<div class="page">{$page}</div>
<php>$sort = ($_GET['sort']=='0') ? '1' : '0';</php>
<table width="100%" cellpadding="3" class="form">
<tbody>
<tr class="top">
      <td align="center" class="tit"><input id="check" onclick="selectAll('sel','checkList');" type="checkbox" name="sel"></td>
<td class="tit"><a title="按照编号" href="{:U('admin/Cms/index',array('p'=>$_GET[p],'order'=>'id','sort'=>$sort))}">编号</a></td>
<td class="tit"><a title="按照标题" href="{:U('admin/Cms/index',array('p'=>$_GET[p],'order'=>'title','sort'=>$sort))}">标题</a></td>
<td class="tit"><a title="按照分类" href="{:U('admin/Cms/index',array('p'=>$_GET[p],'order'=>'category','sort'=>$sort))}">分类</a></td>
<td class="tit"><a title="按照作者" href="{:U('admin/Cms/index',array('p'=>$_GET[p],'order'=>'author','sort'=>$sort))}">作者</a></td>
<td class="tit"><a title="按照发布时间" href="{:U('admin/Cms/index',array('p'=>$_GET[p],'order'=>'publish_time','sort'=>$sort))}">发布时间</a></td>
<td class="tit"><a title="按照状态" href="{:U('admin/Cms/index',array('p'=>$_GET[p],'order'=>'status','sort'=>$sort))}">状态</a></td>
<td class="tit"><a title="操作">操作</a></td>
</tr>
<volist id="vo" name="list">
<tr class="td">
<td align="center"><input name="checkList[]" value="{$vo.id}" type="checkbox"></td>
<td>{$vo.id}</td>
<td>{$vo.title}</td>
<td>{$vo.category|getCmsCateTitle}</td>
<td>{$vo.author}</td>
<td>{$vo.publish_time|friendlyDate}</td>
<td><if condition=" $vo['status'] "> 正常 <else /> 禁用 </if> </td>
<td>

	<php>if($vo['status'] == 0){</php>
		<a href="javascript:resume('{$vo.id}');">恢复</a>
	<php>}else{</php>
		<a href="javascript:forbid('{$vo.id}');">锁定</a>
	<php>}</php>
	<a href="__URL__&act=edit&id={$vo.id}">编辑</a>
	<a href="javascript:del('{$vo.id}');">删除</a>
</td>
</tr>
</volist>

</tbody>
</table>

</div>
<!--  分页显示区域 -->
<div class="page mt10 R mb10">{$page}</div>
<!-- 列表显示区域结束 -->
</fieldset>
<!-- 主体内容结束 -->
<!-- 主页面结束 -->
</div>


</body>
</html>